package com.xtaller.easy.admin.config.interceptor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by Taller on 2018/3/13
 * 拦截器
 */
@Configuration
public class InterceptorConfig extends WebMvcConfigurerAdapter {
    @Bean
    public TokenInterceptor tokenInterceptor(){
        return new TokenInterceptor();
    }
    @Bean
    public AuthInterceptor authInterceptor(){
        return new AuthInterceptor();
    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor()).addPathPatterns("/**/sys/**");
        registry.addInterceptor(tokenInterceptor()).addPathPatterns("/**/base/**");
//
        registry.addInterceptor(authInterceptor()).addPathPatterns("/**/sys/**");
        registry.addInterceptor(authInterceptor()).addPathPatterns("/**/base/**");
    }
}
